﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Reflection;
using System.Text;
using System.Windows.Browser;
using SystemX.Infrastructure;

namespace SalePoints
{
	public partial class About : Page
	{

		public About()
		{
			InitializeComponent();
		}

		#region Member variables
		private string Version
		{
			get
			{
				var tempStrArr = Assembly.GetExecutingAssembly().FullName.Split(',');
				return tempStrArr[1];
			}
		}
		private string CopyRight
		{
			get
			{
				var sb = new StringBuilder();
				sb.AppendLine(Version);
				sb.AppendLine(AssemblyCopyright);
				sb.AppendLine(string.Format("Tip:"));
				sb.AppendLine("						   A,Click the chart title to zoom out the chart!");
				sb.AppendLine("						   B,The chart theme won't effect at once until the data of the chart was refreshed!");
				return sb.ToString();
			}
		}
		/// <summary>
		/// Gets the assembly copyright.
		/// </summary>
		/// <value>The assembly copyright.</value>
		public string AssemblyCopyright
		{
			get
			{
				// Get all Copyright attributes on this assembly
				object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
				// If there aren't any Copyright attributes, return an empty string
				if (attributes.Length == 0)
					return "";
				// If there is a Copyright attribute, return its value
				return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
			}
		} 
		#endregion

		// Executes when the user navigates to this page.
		protected override void OnNavigatedTo(NavigationEventArgs e)
		{
			ContentText.Text = CopyRight;
		}

		private void btnViewLog_Click(object sender, RoutedEventArgs e)
		{
			var logFile="file.axd?file=app.log.txt";
			try
			{
				HtmlPage.Window.Invoke("Popup", logFile);
			}
			catch (Exception ex) { 
			}
		}

	}
}